<template>
	<view class="reportDetail">
		<u-row>
			<u-col span="3">
				<view class="table-th">名称</view>
			</u-col>
			<u-col span="3">
				<view class="table-th">结果</view>
			</u-col>
			<u-col span="3">
				<view class="table-th">{{showDoctor?'医生':'单位'}}</view>
			</u-col>
			<u-col span="3">
				<view class="table-th">{{showDoctor?'时间':'参考范围'}}</view>
			</u-col>
		</u-row>
		<view class="tbody">
			<u-row v-for="(item, i) in dataList" :key='i'>
				<u-col span="3">
					<view class="table-tr">{{item.name||''}}</view>
				</u-col>
				<u-col span="3">
					<view class="table-tr">{{item.resultName||''}}</view>
				</u-col>
				<template v-if="showDoctor">
					<u-col span="3">
						<view class="table-tr">{{item.doctorName||''}}</view>
					</u-col>
					<u-col span="3">
						<view class="table-tr">{{item.inspectionTime||''}}</view>
					</u-col>
				</template>
				<template v-else>
					<u-col span="3">
						<view class="table-tr">{{item.unit||''}}</view>
					</u-col>
					<u-col span="3">
						<view class="table-tr">{{item.referenceRange||''}}</view>
					</u-col>
				</template>
			</u-row>
		</view>
		<Load :load="load" />
	</view>
</template>

<script>
	import Load from '@/components/Load/index.vue'
	import { getReportDetail } from '@/api/physical.js'
	export default {
		components:{ Load },
		data() {
			return {
				load:false,
				healthNo:'',
				reportType:'',
				showDoctor:true,
				dataList:[]
			}
		},
		onLoad(op) {
			this.healthNo = op.healthNo||''
			this.reportType = op.reportType||''
			if(this.reportType==='3'){
				this.showDoctor = false
			}else{
				this.showDoctor = true
			}
			this.initData()
		},
		methods: {
			initData(){
				this.load = true
				getReportDetail({healthNo:this.healthNo, reportType:this.reportType}).then(data => {
					this.load = false
					let res = data||[]
					res.forEach(item => {
						let str = item.result
						if(!this.showDoctor){
							if(item.healthStatus===1){
								str += " ↓"
							}else if(item.healthStatus===2){
								str += " ↑"
							}
						}
						item.resultName = str
					})
					this.dataList = res
					console.log(this.dataList)
				}).catch(e => {
					this.load = false
					this.dataList = []
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.reportDetail{
		min-height: 100%;
		background-color: #FFF;
		.table-th{
			height: 90rpx;
			line-height: 90rpx;
			text-align: center;
			font-size: 30rpx;
			font-weight: bold;
		}
		.tbody{
			margin-top: 10rpx;
			max-height: calc(100vh - 120rpx);
			overflow: scroll;
		}
		.table-tr{
			padding: 10rpx 20rpx;
			font-size: 26rpx;
			text-align: center;
			// word-break:break-all;
			word-wrap: break-word;
			word-break: normal;
		}
	}
</style>
<style lang="scss">
	.u-col{
		padding: 0 !important;
	}
	.tbody{
		.u-row:nth-of-type(2n){
			background-color: #F9F9F9;
		}
	}
</style>
